import torch
import torch.nn as nn
import pandas as pd
import numpy as np


def sharpe_ratio(returns, risk_free_rate=0.0):
    excess_returns = np.array(returns) - risk_free_rate
    return np.mean(excess_returns) / np.std(excess_returns)


def information_ratio(returns, benchmark_returns):
    active_returns = np.array(returns) - np.array(benchmark_returns)
    return np.mean(active_returns) / np.std(active_returns)


def max_drawdown(returns):
    cumulative_returns = (1 + np.array(returns)).cumprod()
    max_return = np.maximum.accumulate(cumulative_returns)
    drawdown = 1 - cumulative_returns / max_return
    return np.max(drawdown)
